More Pugs Fun

Limbic Region on 2005-05-05T19:54:19

Ok - so I was pretty impressed to see that there is already an IRC::Bot written in p6 that Pugs supports. I didn't like the fact that all the configuration settings were hardcoded in the script so I set out to implement Config::Tiny.

I ran into some things that may be bugs but are most likely my misunderstandings

1. Bare blocks are NOT looping constructs like in Perl5. Since next is not implemented yet in Pugs, I thought about doing a bare block with last and was suprised when it didn't work.

2. $fh.say "foo"; doesn't work. You need to use $fh.say("foo"); notice the parens

3. Writing to a file with $fh.say("foo") will result in an empty file if you don't $fh.close. I would have expected this to be automatically handled.

4. I don't think //= doesn't do the right thing. Consider the following: my %hash; %hash //= hash {}; %hash = 42;

I would expect that to "just work". Instead, Pugs makes the following complaint:

*** Error: Cannot cast into Hash: VRef at bug.p6 line 5, column 1-21



5. I am not sure hash {} works correctly when assigning as the value of a hash key but unfortunately my attempts to reduce it to a simple test case have resulted in more problems.

6. In trying to determine if problem number 5 was all hash refs or just with the "hash" keyword, I tried the following:

use v6;

my %foo = ( 'one' => 1, 'two' => 2); my %bar = ( 'me' => 42, 'you' => \%foo, ); %bar. = 42; say %foo;

This resulted in the following error: *** Error: Can't modify constant item: VUndef at bug.p6 line 8, column 1-21

I still need to come up with a test suite for Config::Tiny so this is all for now

Cheers, L~R